<!-- management 页面内容 -->
<section class="management" ng-controller="managementCtrl">
    <empty data='users'></empty>
    <div>
        <div class="title-btn-row">
            <div class="col-md-12 col-sm-12 padding-reset" ng-show="users && users.length > 0 && !isedit" ng-click="isedit = true">
                <button class="btn btn-default pull-right yf-btn">编辑</button>
            </div>
            <div class="col-md-12 col-sm-12 padding-reset" ng-show="isedit">
                <button class="btn btn-default pull-right yf-btn" ng-click="isedit = false">取消</button>
                <button class="btn btn-default pull-right yf-btn" ng-click="saveType();" style="margin-right: 20px;">保存</button>
            </div>
        </div>
        <div class="panel panel-default">
            <div class="panel-heading">
            </div>
            <div class="panel-body">
                <table class="table table-condensed" ng-show='users && users.length > 0'>
                    <thead>
                        <tr>
                            <th class="col-sm-2">
                                序号
                            </th>
                            <th class="col-sm-4">
                                邮箱
                            </th>
                            <th class="col-sm-2">
                                姓名
                            </th>
                            <th class="col-sm-2">
                                部门
                            </th>
                            <th class="col-sm-2">
                                角色
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="user in users track by $index">
                            <td>{{ $index + 1 }}</td>
                            <td>{{ user.email }}</td>
                            <td>{{ user.real_name }}</td>
                            <td>{{ user.department.name}}</td>
                            <td ng-show="!isedit">{{ user.department.role_name }}</td>
                            <td ng-show="isedit">
                                <select ng-model='user.department' ng-change="selectRoles(user, $index);" ng-options="dt as dt.name for dt in departments" style="margin-bottom: 5px;"></select>
                                <select ng-model='user.depart_role_id' ng-show="user.department" ng-change="setUserType(user, $index);" ng-options="role.id as role.name for role in user.department.depart_roles"></select>
                            </td>
                        </tr>
                    </tbody>
                </table>
                <nav ng-show='users && users.length != 0 && page.total_count > limit'>
                    <ul class="pager pager-sm yf-pager">
                        <li>
                            <a class="btn btn-default" ng-disabled="!((page.current_page - 1) >= 1)" ng-click="manage(page.current_page - 1);">上一页</a>
                        </li>
                        <li>
                            <a class="btn btn-default" ng-disabled="!page.next_page" ng-click="manage(page.next_page);">下一页</a>
                        </li>
                    </ul>
                </nav>
            </div>
        </div>
    </div>
</section>
